//: [Previous](@previous)

import Foundation
import UIKit

var str = "Hello, playground"

//: [Next](@next)



let view = UIView(frame: CGRect(x: 0, y: 0, width: 50, height: 50))
view.clipsToBounds = true



extension UIView {
    @discardableResult
    public func setAsCircle() -> Self{
        self.clipsToBounds = true
        let frameSize = self.frame.size
        self.layer.cornerRadius = min(frameSize.width, frameSize.height) / 2.0
        
        return self;
    }
}

view.setAsCircle()


extension UIView {
    func shake(){
        let animation = CAKeyframeAnimation(keyPath: "transform.translation.x")
        animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionLinear)
        animation.duration = 0.6
        animation.values = [-10.0, 10.0, -7.0, 7.0, -5.0, 5.0, 0.0]
        layer.add(animation, forKey: "shake")
    }
}

view.shake()





